Repository navigation
Conversation
The for_each_signal! X-macro that generates SIGNAL_NAMES and SignalCode had a placeholder entry SIG16 = 16 instead of SIGSTKFLT = 16. As a result, a child killed by signal 16 was reported as 'SIG16' in the exit/close event signal argument and in subprocess.signalCode, while Node.js reports 'SIGSTKFLT' and Bun's own os.constants.signals already maps SIGSTKFLT to 16.
|
Updated 3:04 PM PT - Jul 8th, 2026
❌ @robobun, your commit 639fb28 has 4 failures in
🧪 To try this PR locally: bunx bun-pr 33775That installs a local version of the PR into your bun-33775 --bun |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR fixes an incorrect signal name in the ChangesSIGSTKFLT naming fix
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
LGTM — one-token rename in the signal table (SIG16 → SIGSTKFLT) with a solid Linux-gated regression test.
Extended reasoning...
Overview
This PR changes exactly one token in src/bun_core/Global.rs: the for_each_signal! X-macro entry SIG16 = 16 becomes SIGSTKFLT = 16. All consumers of signal names (SIGNAL_NAMES, the SignalCode enum, from_raw/from_name, and bun_sys::SignalCode associated consts) are generated from this macro, so the rename propagates automatically. A Linux-only regression test in test/js/node/child_process/child_process.test.ts round-trips child.kill("SIGSTKFLT") and asserts the exit event reports {signal: "SIGSTKFLT", signalCode: "SIGSTKFLT"} instead of the invented "SIG16".
I grepped the tree: SIG16 no longer appears anywhere in src/ (only in the new test's comment/title as historical context), and SIGSTKFLT was already the spelling used by os.constants.signals, ProcessBindingConstants.cpp, and NodeConstantsModule.h — this fix brings the signal-name reporting path into agreement with the rest of the codebase and with Node.js.
Security risks
None. This is a static string-table entry rename. No parsing of untrusted input, no auth/crypto/permission surface, no memory or lifetime changes.
Level of scrutiny
Low. The change is a single identifier in a data table whose purpose is explicitly to be the sole source of truth for signal names. SIG16 was clearly a placeholder (the only numeric-suffix entry in the table), and nothing referenced it by name. The behavioral surface is limited to the string reported for signal 16 on child exit — moving from a made-up value to the POSIX/Node-documented one is strictly a compatibility improvement.
Other factors
The test follows repo conventions well: gated with it.if(isLinux) (SIGSTKFLT is Linux-specific), wires error to reject, awaits the spawn event before killing, and asserts the full {code, signal, signalCode} object. The os import addition is clean. No outstanding reviewer comments; CI build was triggered. This is the kind of mechanical data fix that doesn't need human review.
There was a problem hiding this comment.
LGTM — one-token rename in the signal name table with a matching regression test.
Extended reasoning...
Overview
This PR renames a single entry in the for_each_signal! X-macro in src/bun_core/Global.rs from the placeholder SIG16 = 16 to the correct SIGSTKFLT = 16, and adds a Linux-only regression test in test/js/node/child_process/child_process.test.ts that verifies child.kill("SIGSTKFLT") round-trips to signal === "SIGSTKFLT" on the exit event.
Security risks
None. This is a string-constant rename in a static lookup table; no untrusted input handling, auth, crypto, or permissions logic is touched.
Level of scrutiny
Low. The source change is a one-token data fix in a generated-from-macro table. I confirmed via grep that nothing in src/ references SignalCode::SIG16 or the string "SIG16", so the rename cannot break any consumer. SIGSTKFLT already appears in NodeConstantsModule.h and ProcessBindingConstants.cpp with value 16, so this brings the Rust table into agreement with the existing C++ constants and with Node.js. The macro comment explicitly states it is the single source of truth for SIGNAL_NAMES, SignalCode, and from_name, so all downstream consumers pick up the correction automatically.
Other factors
The new test is well-constructed: gated on isLinux (SIGSTKFLT is Linux-specific), wires error to reject, awaits the spawn event before killing, and asserts an exact object equality on {code, signal, signalCode}. It follows the neighboring test patterns in the file. Neither modified file is covered by CODEOWNERS. The bug-hunting system found no issues, and there are no outstanding reviewer comments.
|
CI is red on unrelated flakes; the diff itself is green.
Neither build flagged |
|
Superseded by #39970, which renames slot 16 to SIGSTKFLT as part of mapping signal numbers per platform, and carries a test for it. |
…umbers (#39970) Fixes #35296 ### Problem - On macOS, `subprocess.signalCode` names the platform's number with the Linux table: a child killed by SIGBUS (10 there) reports `"SIGUSR1"` (build 102638). `kill("SIGUSR1")` sends 10, which is SIGBUS there. - A signal with no name (a Linux real-time signal) is handled four ways: `exited` is 128 + n or 254, `bun run` exits 1, `Bun.$` never completes, and `signalCode` is null. - Cause: `bun_core::SignalCode` (`src/bun_core/Global.rs:239`) has Linux numbers on every platform. `Status::signal_code()` (`src/spawn/process.rs:768`) looked the raw `WTERMSIG` number up in it, and `kill()` sent the table's number. ### Fix - `bun_core::SignalCode` holds only the signals the target has, and a discriminant is the target's own number: `libc::SIG*` on unix, the CRT and libuv numbers on Windows. `platform_number()` (#34660) and each `None` fallback are gone. Signal 16 on Linux is `SIGSTKFLT`, node's name. - `Status::signal()` is the raw platform number. Exit codes, re-raises and `signalCode` use it. `Status::signal_code()` is the named signal, used only to name or classify. - Correct because a variant cannot exist without a number, so each conversion to the OS is a cast. A number without a name is reported as the number. A name the platform lacks is an unknown name. - Verified: new cases in seven test files (see the notes), with cases that fail on stock bun on Linux. Also `cargo check` for five targets and a Windows debug build. ### Background - Signal numbers are per OS. Linux and the BSDs agree on about half of them. SIGSTKFLT and real-time signals are Linux-only. Windows has six CRT signals, and libuv adds four. - `bun_core::SignalCode` is a closed enum generated from one table. Its variant names are what JS sees. - `bun_sys::SignalCode(u8)` is the open newtype for any platform number, which may have no name. <details><summary>Notes</summary> - New test cases: spawn-kill-signal, child_process, shell-hang, run-propagate-sigkill, filter-workspace, bun-install-lifecycle-scripts, parallel. - Superseded and closed: #33775 (the SIGSTKFLT name), #32305 and #32321 (a signal with no name). - Shape history: the first version kept the Linux-numbered table and converted at the OS boundary with `platform_number()` and a new inverse. Review asked for no abort or panic fallbacks, so the table itself is per platform now. `raise_ignoring_panic_handler()` is unchanged from main (`sig as c_int` is correct once a discriminant is the platform's number), `bun_sys::SignalCode::of()` is a cast, the kill-signal parser has no `ERR_UNKNOWN_SIGNAL` branch, and `--watch-kill-signal` has no `platform_number().is_some()` filter and no `unwrap_or(SIGTERM)`. The one `Option` left is `from_number()`, because a real-time signal has no name. - The table: the unix rows take their numbers from `libc`, so there is no per-OS numbering to keep in sync, and the compiler rejects two variants with one number. SIGSTKFLT and SIGPWR are `cfg(any(linux, android))`. The Windows rows are the ten numbers `platform_number()` had (CRT plus libuv's `uv/win.h`). A row also carries the description for the "terminated by" messages, so the `description()` match in `bun_sys` is gone and no consumer needs a `cfg`. - A name the platform lacks: on macOS `kill("SIGPWR")` used to send signal 30, which is SIGUSR1 there. On Windows `kill("SIGUSR1")` used to throw the `ENOSYS` system error from `uv_kill`. Both now throw the existing `ERR_INVALID_ARG_TYPE` error, the same as `"SIGGOD"`, and its list holds only the platform's names. On Windows the list is `'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGABRT', 'SIGFPE', 'SIGKILL', 'SIGSEGV', 'SIGTERM' or 'SIGWINCH'`. `--watch-kill-signal` keeps its `ERR_UNKNOWN_SIGNAL` message. node:child_process validates names in JS against `os.constants.signals`, as before. The test for this runs on macOS and Windows with SIGSTKFLT and SIGPWR. On Linux every name exists. - Windows call sites: `on_exit_uv` used `term_signal < SIGSYS` as its range check. SIGSYS is not a Windows signal, so the check is `u8::try_from(term_signal)` with 0 excluded. libuv sets `term_signal` only to a signal `uv_process_kill` accepted (SIGINT, SIGQUIT, SIGKILL, SIGTERM). `is_panic_status` reads signals only on unix. On Windows a signal status comes only from `uv_process_kill`, and none of those four is a crash signal, so the result is the same. - Surfaces that read the name: `subprocess.signalCode`, `onExit`, `Bun.spawnSync().signalCode`, node:child_process `exit`/`close`/`signalCode` and `spawnSync().signal`, the `bun test --parallel` "worker crashed" label, the `bun run --filter` label, and the `bun run` and lifecycle-script "terminated by" messages. `bun test --parallel` also classifies SIGBUS and SIGSYS deaths as crashes through the table. On macOS those two were read as SIGUSR1 and SIGUSR2 and did not abort the run, and a SIGUSR2 death was read as SIGSYS and did. - Surfaces that use the number: the `exited` promise (the one created before the exit and the one created after, which used to give 254), the shell's `$?` (the shell used to wait forever for a command killed by a real-time signal, reproduced on stock bun), the `bun run --filter` and `bun create` exit codes (used to be 1), the `bun run`, `bunx` and lifecycle re-raises (the lifecycle one used to re-raise SIGTERM), and the number the webview hooks pass to C++. - `Bun.spawn`'s `signalCode` for a signal with no name is the number. `bun.d.ts` documented that, and the code did it before the Rust port. `bun.d.ts` and `docs/runtime/child-process.mdx` now say so in the types too (`onExit`'s parameter was typed `number | null` although it received the name). - node:child_process keeps names only and reports such a death as Node does. Under Node v26.3.0 on Linux, `spawn("sh", ["-c", "kill -40 $$"])` gives `exit` and `close` `(0, null)`, `exitCode: 0`, `signalCode: null`, and `spawnSync` gives `{ status: null, signal: "" }`: `signo_string()` is `""` for a signal Node has no name for ([process_wrap.cc#L410](https://github.com/nodejs/node/blob/v26.3.0/src/process_wrap.cc#L410), [spawn_sync.cc#L732](https://github.com/nodejs/node/blob/v26.3.0/src/spawn_sync.cc#L732)), so `onexit` stores libuv's exit status, 0 ([child_process.js#L270](https://github.com/nodejs/node/blob/v26.3.0/lib/internal/child_process.js#L270)). Bun reported `(null, null)` and `signal: null`, a state Node never produces, and cluster's `isDead()` stayed false after the exit. - Fail-before on Linux comes from the Linux-visible half of each class: signal 16 was named `SIG16`, `kill("SIGSTKFLT")` threw, the CLI printed `code 16` for it, and signal 40 (a real-time signal on glibc and musl) hit every no-name path. The macOS half is covered by the same tests through SIGUSR1/SIGUSR2, which pass on Linux either way. - #35304 fixes the naming with a second X-macro table of BSD numbers. After #34660 landed `platform_number()`, that table does not build on macOS (`platform_number()` names `SIGPWR`, and the BSD table adds `SIGEMT`/`SIGINFO` variants it does not match). - `from_number()` is a linear search over the variants, once per process exit. `raise_ignoring_panic_handler_raw()` is untouched, so this does not overlap with #38877. - Removed as dead: `platform_number()`, `SIGNAL_NAMES`, `bun_core::SignalCode::from_raw()`, `bun_sys::signal_code::from_name()`, the generated `bun_sys::SignalCode::SIG*` constants (only `SIGINT`, `SIGKILL` and `DEFAULT` have users), the `description()` match in `bun_sys`, `Process::signal_code()` and the `SignalCodeExt` shim. - The tests use SIGUSR1, SIGUSR2 and, on Linux, SIGSTKFLT, because their numbers differ between Linux and the BSDs and their default action terminates without a core dump, and signals 40 and 64 for the no-name paths. The async spawn tests assert `exited === 128 + os.constants.signals[name]` as well as the name. On macOS the old code sent the wrong signal and then named it with the same wrong table, so the name alone passed. The parallel test kills with an `os.constants` number because `process.kill(pid, "SIGSTKFLT")` is a separate gap (#33776), and ASAN builds intercept a self-sent SIGBUS. - The branch is one commit on top of main plus review follow-ups. Two call sites that were new on main were adapted during the rebase: `Coordinator::abort_all` (#41467) drops `.unwrap_or(130)` because `to_exit_code()` is total, and `git_runner.rs` (#40734) uses `bun_sys::SignalCode::SIGKILL`. The shell's `Status::Err` arm (a wait error leaves `Bun.$` pending) is the same on main and is handed off as separate work. - Suites run with the Linux debug build: spawn, spawnSync, spawn-signal, spawn-maxbuf, spawn-kill-signal, bunshell, exec, shelloutput, shell-hang, filter-workspace, run-propagate-sigkill, run-crash-handler, run_command, child_process, child_process-node, parallel.test.ts, the signal cases of bun-install-lifecycle-scripts.test.ts, the three `test-watch-mode-kill-signal-*.mjs` node tests, and test/integration/bun-types. `cargo check` ran for `bun_core`, `bun_sys`, `bun_spawn`, `bun_jsc`, `bun_runtime` and `bun_install` on linux, aarch64 darwin, x86_64 windows-msvc, android and freebsd. `cargo clippy` is clean for those crates on the host. - With a Windows debug build: spawn-kill-signal.test.ts, run-crash-handler.test.ts, the signal cases of child_process.test.ts, the NTSTATUS case of parallel.test.ts, `kill("SIGKILL")` (exited 137, `signalCode` `"SIGKILL"`), and `--watch --watch-kill-signal SIGUSR1` (`ERR_UNKNOWN_SIGNAL`, exit 1). - Unrelated, seen on the way: in the Windows debug build, five other `parallel.test.ts` cases fail because the worker prints `ASSERTION FAILED: currentThreadIsHoldingAPILock()` from `JSC::VM::finalizeSynchronousJSExecution` (called from `run_as_worker` through `release_weak_refs`). The assertion is debug-only, this diff does not touch that code, and the release lanes in CI pass those cases. In this Linux container, `child_process.test.ts` has two unrelated failures: "should allow us to spawn in the default shell" (`$SHELL` is empty here) and "extra stdio pipes are not double-closed on GC" (20 debug+ASAN bun startups exceed the 5 s test timeout). "each worker has a unique JEST_WORKER_ID" in `parallel.test.ts` fails one run in three here, because a debug worker starts slower than the 200 ms the fixture sleeps. </details> <!-- robobun:evidence:begin --> --- **no test proof** · iteration 6 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/js/node/child_process/child_process.test.ts, test/js/bun/spawn/spawn-kill-signal.test.ts, test/js/bun/shell/shell-hang.test.ts, test/cli/test/parallel.test.ts, test/cli/run/run-propagate-sigkill.test.ts, test/cli/run/filter-workspace.test.ts, test/cli/install/bun-install-lifecycle-scripts.test.ts <!-- robobun:evidence:end -->
Problem
On Linux, when a child process is killed by signal 16 (SIGSTKFLT), Bun reports the signal name as the invented string
"SIG16"in theexit/closeevent argument and insubprocess.signalCode. Node.js reports"SIGSTKFLT"."SIG16"is not a real signal name. It appears nowhere in POSIX, Node's docs, or Bun's ownos.constants.signals(which correctly hasSIGSTKFLT === 16). Code that switches on documented signal names (process managers, lifecycle runners, signal-exit-style libraries) receives an impossible value and falls through.It was also internally inconsistent:
child.kill("SIGSTKFLT")accepts the name and delivers signal 16, then reports the resulting death as"SIG16".Cause
The
for_each_signal!X-macro insrc/bun_core/Global.rs, which is the single source of truth forSIGNAL_NAMES,SignalCode, andfrom_name, had a placeholder entrySIG16 = 16instead ofSIGSTKFLT = 16. No other numeric placeholders exist in the table, and nothing in the tree referencesSignalCode::SIG16by name.Fix
Rename the entry to
SIGSTKFLT. All downstream consumers (exit-status naming,subprocess.signalCode,bun_sys::SignalCodeassociated consts,from_name) are generated from this macro.Verification
New test in
test/js/node/child_process/child_process.test.ts(Linux-only; SIGSTKFLT is Linux-specific) asserts the round trip:child.kill("SIGSTKFLT")followed byexitevent reporting{signal: "SIGSTKFLT", signalCode: "SIGSTKFLT"}.Before / after
Before (bun 1.4.0):
After: